package jpb.module.service.apply;

import jpb.module.dao.apply.ApplyDao;
import jpb.module.dao.organize.OrganizeDao;
import jpb.module.dao.organize.OrganizeMemDao;
import jpb.module.daomain.apply.Apply;
import jpb.module.daomain.organize.Organize;
import jpb.util.DateFormatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by haol on 2017/5/7.
 */
@Service
public class ApplyService {
        @Autowired
        private ApplyDao applyDao;

        @Autowired
        private OrganizeDao organizeDao;
        @Autowired
        private OrganizeMemDao organizeMemDao;

        public void addApply(Apply apply){
                apply.setApplyTime(DateFormatUtil.getYMdHm());
                applyDao.add(apply);
        }


       public List<Apply> getApplyByOidAndStateIsZero(String oid){
                        return applyDao.getApplyByOidAndStateIsZero(oid);
       }
        public List<Apply> getApplyByOid(String oid){
                return applyDao.getApplyByOid(oid);
        }
        public Apply getByOid(Integer id) {

                        return applyDao.getById(id);

        }

        public List<Apply> getByNum(String num){
                return applyDao.getByNum(num);
        }
        public void update(Apply apply){
                applyDao.update(apply);
        }

        public List<Apply> getByOidAndState(String oid,int state,String num){
                return applyDao.getByOidAndState(oid,state,num);
        }

        public void delete(Integer id){
                applyDao.delete(id);
        }

        public boolean getMemByOidAndMum(String oid,String memberNum){
                        return organizeMemDao.queryByOidNum(oid,memberNum) == 0;
        }

        public Organize getOrganize(String oid){
                return organizeDao.get(oid);
        }
}
